<?php /*a:3:{s:77:"C:\Users\Administrator\PhpstormProjects\test\app\index\view\member.index.html";i:1594816716;s:36:"../app/index/view/public.header.html";i:1594816716;s:36:"../app/index/view/public.footer.html";i:1594816716;}*/ ?>
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Admin</title>
    <script type="text/javascript" src="/plug/layui/layui.js"></script>
    <script type="text/javascript" src="/static/script/common.js"></script>
    <script type="text/javascript" src="/static/script/moment.min.js"></script>
    <link rel="stylesheet" type="text/css" href="/plug/awesome/css/font-awesome.css" />
    <link rel="stylesheet" type="text/css" href="/plug/layui/css/layui.css" />
    <link rel="stylesheet" type="text/css" href="/static/css/common.css" />
</head>
<body>

<div class="layui-card">
    <div class="layui-card-body">
        <form class="layui-form layui-form-pane mt8">
            <div class="layui-form-item">
                <div class="layui-input-inline">
                    <input class="layui-input" name="mobile" id="mobile" type="text" placeholder="请输入手机号"
                           value="<?php echo htmlentities($mobile); ?>" autocomplete="off" lay-verify="title"/>
                </div>
                <div class="layui-input-inline">
                    <input class="layui-input" name="name" id="name" type="text" placeholder="请输入姓名" value="<?php echo htmlentities($name); ?>"
                           autocomplete="off" lay-verify="title"/>
                </div>
                <div class="layui-btn-group">
                    <a class="layui-btn layui-btn-primary" id="search"><i class="fa fa-search fa-fw"></i> 搜索数据</a>
                    <a class="layui-btn layui-btn-primary" id="add"><i class="fa fa-plus fa-fw"></i> 添加数据</a>
                    <a class="layui-btn layui-btn-primary" id="batch"><i class="fa fa-xing fa-fw"></i> 批量删除</a>
                    <a class="layui-btn layui-btn-primary" id="modify"><i class="fa fa-edit fa-fw"></i> 批量修改</a>
                </div>
                <!--<div class="layui-table-tool-self">
                    <div class="layui-inline" title="筛选列" lay-event="LAYTABLE_COLS">
                        <i class="layui-icon layui-icon-cols"></i>
                        <ul class="layui-table-tool-panel">
                            <li>
                                <div class="layui-unselect layui-form-checkbox layui-form-checked" lay-skin="primary">
                                    <span>用户ID</span>
                                    <i class="layui-icon layui-icon-ok">
                                    </i>
                                </div>
                            </li>
                            <li>
                                <div class="layui-unselect layui-form-checkbox layui-form-checked" lay-skin="primary">
                                    <span>用户名手机号</span>
                                    <i class="layui-icon layui-icon-ok"></i>
                                </div>
                            </li>
                            <li>
                                <div class="layui-unselect layui-form-checkbox layui-form-checked" lay-skin="primary">
                                    <span>用户手机号</span>
                                    <i class="layui-icon layui-icon-ok"></i>
                                </div>
                            </li>
                        </ul>
                    </div>
                    <div class="layui-inline" title="导出" lay-event="LAYTABLE_EXPORT">
                        <i class="layui-icon layui-icon-export"></i>
                    </div>
                    <div class="layui-inline" title="打印" lay-event="LAYTABLE_PRINT">
                        <i class="layui-icon layui-icon-print"></i>
                    </div>
                    <div class="layui-inline" title="提示" lay-event="LAYTABLE_TIPS">
                        <i class="layui-icon slayui-icon-tip"></i>
                    </div>
                </div>-->
            </div>
        </form>
        <table class="layui-table" lay-data="{height: 'full-78', cellMinWidth: 80,url:'http://127.0.0.1/index.php/index/member/getlist/?mobile=<?php echo htmlentities($mobile); ?>&name=<?php echo htmlentities($name); ?>',
        page:true,limit:'100',limits:[100,200,300,400],skin:'line',even:'true',id:'table'}" lay-filter="table1">
            <thead>
            <tr>
                <th lay-data="{checkbox:true,fixed:true}"></th>
                <th lay-data="{field:'member_id'}">用户ID</th>
                <th lay-data="{field:'member_mobile'}">用户手机号</th>
                <th lay-data="{field:'member_name'}">用户姓名</th>
                <th lay-data="{field:'member_age'}">用户年龄</th>
                <th lay-data="{field:'add_time'}">添加时间</th>
                <th lay-data="{fixed:'right',align:'center',width:200,toolbar:'#toolbar'}">操作</th>
            </tr>
            </thead>
        </table>
    </div>
</div>
<script type="text/html" id="toolbar">
    <a class="layui-btn layui-btn-primary layui-btn-xs" lay-event="detail">查看</a>
    <a class="layui-btn layui-btn-xs" lay-event="edit">编辑</a>
    <a class="layui-btn layui-btn-xs" lay-event="delete">删除</a>
</script>
<script type="text/javascript">
    layui.use(["layer", "form", "table", "upload", "element", "laydate"], function () {
        layui.jquery("#search").click(function () {
            location.href = "http://127.0.0.1/index.php/index/member/index/?mobile="
                + layui.jquery("#mobile").val() + "&name=" + layui.jquery("#name").val();//搜索数据
        });
        layui.jquery("#add").click(function () {
            showIFrame("添加数据", "http://127.0.0.1/index.php/index/member/add/")
        });
        layui.jquery("#batch").click(function () {
            let id = "";
            let data = layui.table.checkStatus("table").data;
            if (data.length === 0) {
                showMessage("尚未选择数据~", 2);
                return
            }
            layui.jquery.each(data, function (position, item) {
                id = id + item.member_id + ',';
            });
            get("http://127.0.0.1/index.php/index/member/batch/?id=" + id, function (result) {
                closeAll();
                if (jsonFailure(result)) {
                    showMessage(jsonMsg(result), 2);
                    return;
                }
                showMessage("已删除成功~", 1, function () {
                    location.reload();
                });
            });
        });
        layui.jquery("#modify").click(function () {
            let id = "";
            let data = layui.table.checkStatus("table").data;
            if (data.length === 0) {
                showMessage("尚未选择数据~", 2);
                return
            }
            layui.jquery.each(data, function (position, item) {
                id = id + item.member_id + ',';
            });
            showIFrame("批量修改", "http://127.0.0.1/index.php/index/member/modify/?id=" + id);
        });

        /*var table = layui.table;

        layui.table.render({
            elem: '#test',
            url: '/test/table/demo1.json',
            toolbar: '#toolbarDemo',
            defaultToolbar: ['filter', 'exports', 'print', {
                class:'layui-inline',
                title: '提示'
                , layEvent: 'LAYTABLE_TIPS'
                , icon: 'layui-icon-tips'
            }]
            , cols: [[
                {type: 'checkbox', fixed: 'left'}
                ,{field: 'member_id', title: 'ID'}
                , {field: 'member_name', title: '用户名'}
                , {field: 'member_mobile', title: '手机号'}
                , {field: 'member_age', title: '用户年龄'}
                , {field: 'add_time', title: '添加时间'}
            ]]
            , page: true
        });
        layui.table.on('toolbar(test)', function (object) {
            switch (object.event) {
                case 'LAYTAVLE_TIPS':
                    layer.alert('图标');
                    break;
            }
        });*/


        //双击事件
        layui.table.on("rowDouble(table1)", function (object) {
            // <var> 标签表示变量的名称，或者由用户提供的值。 data直接赋值数据
            var data = object.data;
            //定义文档标题
            layer.alert(JSON.stringify(data), {
                title: '当前行数据'
            });
            //标注选中样式
            object.tr.addClass('layui-bable-click').siblings().removeClass('layui-table-click');
        });


        layui.table.on("tool(table1)", function (object) {
            //查看
            if (object.event === "detail") {
                layer.msg('ID:' + object.data.member_id + '的查看操作'); //msg解析提示文本
            }
            //编辑
            if (object.event === "edit") {
                showIFrame("查看数据", "http://127.0.0.1/index.php/index/member/edit/?id=" + object.data.member_id);
            }
            //删除
            if (object.event === "delete") {
                get("http://127.0.0.1/index.php/index/member/delete/?id=" + object.data.member_id, function (result) {
                    closeAll();
                    if (jsonFailure(result)) {
                        showMessage(jsonMsg(result), 2);
                        return;
                    }
                    showMessage("删除成功~", 1, function () {
                        location.reload();
                    });
                });
            }
        });
    });
</script>
</body>
</html>

